package com.d3works.apps.stock.service;

import com.d3works.apps.stock.db.StockHistoryLine;
import com.d3works.exception.D3worksException;
import com.d3works.meta.db.MetaFile;
import java.io.IOException;
import java.time.LocalDate;
import java.util.List;

public interface StockHistoryService {

  /**
   * Compute lines for stock history. Compute one line per month between beginDate and endDate and
   * add two lines for average and total.
   *
   * @param productId id of the queried product, cannot be null.
   * @param companyId id of the company used as filter, cannot be null.
   * @param stockLocationId id of the stock location used as filter, cannot be null.
   * @param beginDate mandatory date used for the generation.
   * @param endDate mandatory date used for the generation.
   * @return the computed lines.
   */
  List<StockHistoryLine> computeStockHistoryLineList(
      Long productId, Long companyId, Long stockLocationId, LocalDate beginDate, LocalDate endDate)
      throws D3worksException;

  MetaFile exportStockHistoryLineList(List<StockHistoryLine> stockHistoryLineList, String fileName)
      throws IOException;

  public String getStockHistoryLineExportName(String productName);

  /**
   * Same as {@link StockHistoryService#computeStockHistoryLineList(Long, Long, Long, LocalDate,
   * LocalDate)} But, this method will save the computed stock history lines
   *
   * @param productId
   * @param companyId
   * @param stockLocationId
   * @param beginDate
   * @param endDate
   * @return
   * @throws D3worksException
   */
  List<StockHistoryLine> computeAndSaveStockHistoryLineList(
      Long productId, Long companyId, Long stockLocationId, LocalDate beginDate, LocalDate endDate)
      throws D3worksException;
}
